package com.chendechao.model_home.ui.recommend.comment


import androidx.lifecycle.ViewModel
import com.chendechao.lib_base.BaseViewModel
import com.chendechao.model_home.model.RecommendMutilVideo
import com.chendechao.model_home.ui.recommend.RecommendIntent
import com.chendechao.model_home.ui.recommend.RecommendUIState

import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject

@HiltViewModel
class CommentViewModel @Inject constructor(val repository: CommentRepository): BaseViewModel<CommentUIState, CommentIntent>(CommentUIState()) {
    override suspend fun handleEvent(event: CommentIntent) {
        when (event) {
            is CommentIntent.LoadData -> loadData()
        }
    }

    private suspend fun loadData() {
        val res =  repository.getCommentListData()
        res.onSuccess {
            updateState(CommentUIState(comentData = it.comentData,  isSucess = true))
        }.onFailure {

        }
    }
}